﻿
Namespace internalFunctions
    Public MustInherit Class _timefromticks
        Inherits inputIFunction(Of Int64, String)

        Protected Sub New(ByVal name As String)
            MyBase.New(name)
        End Sub

        Protected NotOverridable Overrides Function finder() As iVariableFinder(Of Int64)
            Return int_finder()
        End Function

        Protected NotOverridable Overrides Function returnType() As typeDefination
            Return typeDefination.string
        End Function
    End Class

    Public MustInherit Class _timeoper
        Inherits inputIFunction(Of Int64, Int64)

        Protected Sub New(ByVal name As String)
            MyBase.New(name)
        End Sub

        Protected NotOverridable Overrides Function finder() As iVariableFinder(Of Int64)
            Return int_finder()
        End Function

        Protected NotOverridable Overrides Function returnType() As typeDefination
            Return typeDefination.int
        End Function
    End Class

    'paramters, NA
    'return, string, the long formatted time
    Public Class timelong
        Inherits internalFunction

        Public Class paramaters
        End Class

        Public Sub New()
            MyBase.new("time.long")
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            output = New bare_variable(typeDefination.string, longTime())
            Return True
        End Function
    End Class

    'paramters, NA
    'return, string, the short formatted time
    Public Class timeshort
        Inherits internalFunction

        Public Class paramaters
        End Class

        Public Sub New()
            MyBase.New("time.short")
        End Sub

        Protected Overrides Function invoke(ByVal ctx As context, ByRef output As bare_variable) As Boolean
            output = New bare_variable(typeDefination.string, shortTime())
            Return True
        End Function
    End Class

    Public Class timeticks
        Inherits noInputFunction(Of Int64)

        Public Sub New()
            MyBase.New("time.ticks")
        End Sub

        Protected Overrides Function invoke(ByRef o As Int64) As Boolean
            o = Now.Ticks()
            Return True
        End Function

        Protected Overrides Function returnType() As typeDefination
            Return typeDefination.int
        End Function
    End Class

    Public Class shorttimefromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.shorttime.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = shortTime(New Date(i))
            Return True
        End Function
    End Class

    Public Class longtimefromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.longtime.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = longTime(New Date(i))
            Return True 
        End Function
    End Class

    Public Class yearfromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.year.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = (New Date(i)).Year()
            Return True
        End Function
    End Class

    Public Class monthfromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.month.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = (New Date(i)).Month()
            Return True
        End Function
    End Class

    Public Class datefromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.date.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = (New Date(i)).Day()
            Return True
        End Function
    End Class

    Public Class dayofweekfromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.dayofweek.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = (New Date(i)).DayOfWeek()
            Return True
        End Function
    End Class

    Public Class dayofyearfromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.new("time.dayofyear.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = (New Date(i)).DayOfYear()
            Return True
        End Function
    End Class

    Public Class hourfromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.hour.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = (New Date(i)).Hour()
            Return True
        End Function
    End Class

    Public Class minutefromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.minute.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = (New Date(i)).Minute()
            Return True
        End Function
    End Class

    Public Class secondfromticks
        Inherits _timefromticks

        Public Sub New()
            MyBase.New("time.second.fromticks")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As String) As Boolean
            o = (New Date(i)).Second()
            Return True
        End Function
    End Class

    Public Class _thisyear
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.thisyear")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = thisyear(i)
            Return True
        End Function
    End Class

    Public Class _thismonth
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.thismonth")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = thismonth(i)
            Return True
        End Function
    End Class

    Public Class _thisweek
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.thisweek")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = thisweek(i)
            Return True
        End Function
    End Class

    Public Class _thisday
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.thisday")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = thisday(i)
            Return True
        End Function
    End Class

    Public Class _thishour
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.thishour")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = thishour(i)
            Return True
        End Function
    End Class

    Public Class _thisminute
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.thisminute")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = thisminute(i)
            Return True
        End Function
    End Class

    Public Class _thissecond
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.thissecond")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = thissecond(i)
            Return True
        End Function
    End Class

    Public Class _thismillisecond
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.thismillisecond")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = thismillisecond(i)
            Return True
        End Function
    End Class

    Public Class _lastyear
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.lastyear")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = lastyear(i)
            Return True
        End Function
    End Class

    Public Class _lastmonth
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.lastmonth")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = lastmonth(i)
            Return True
        End Function
    End Class

    Public Class _lastweek
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.lastweek")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = lastweek(i)
            Return True
        End Function
    End Class

    Public Class _lastday
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.lastday")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = lastday(i)
            Return True
        End Function
    End Class

    Public Class _lasthour
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.lasthour")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = lasthour(i)
            Return True
        End Function
    End Class

    Public Class _lastminute
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.lastminute")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = lastminute(i)
            Return True
        End Function
    End Class

    Public Class _lastsecond
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.lastsecond")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = lastsecond(i)
            Return True
        End Function
    End Class

    Public Class _lastmillisecond
        Inherits _timeoper

        Public Sub New()
            MyBase.New("time.lastmillisecond")
        End Sub

        Protected Overrides Function invoke(ByVal i As Int64, ByRef o As Int64) As Boolean
            o = lastmillisecond(i)
            Return True
        End Function
    End Class
 end Namespace